﻿using System.Configuration;
using System;
using console.demo;
using console.demo.senior;
using console.demo.linq;
using console.demo.thread;

namespace console;
public class Program
{
    static void Main(string[] args)
    {
        // 三种策略提供选择
        // Context context;
        // context = new Context(new ConcreteStrategyA());
        // context.ContextInterface();
        // context = new Context(new ConcreteStrategyB());
        // context.ContextInterface();
        // context = new Context(new ConcreteStrategyC());
        // context.ContextInterface();
        // Console.ReadKey();

        // LoadBalancer b1 = LoadBalancer.GetLoadBalancer();
        // LoadBalancer b2 = LoadBalancer.GetLoadBalancer();
        // LoadBalancer b3 = LoadBalancer.GetLoadBalancer();
        // LoadBalancer b4 = LoadBalancer.GetLoadBalancer();
        // // Same instance?
        // if (b1 == b2 && b2 == b3 && b3 == b4)
        // {
        //     Console.WriteLine("Same instance\n");
        // }
        // LoadBalancer balancer = LoadBalancer.GetLoadBalancer();
        // for (int i = 0; i < 15; i++)
        // {
        //     string server = balancer.Server;
        //     Console.WriteLine("Dispatch Request to: " + server);
        // }
        // // Wait for user
        // Console.ReadKey();
        // Creator[] creators=new Creator[2];
        // creators[0]=new ConcreteCreateA();
        // creators[1]=new ConcreteCreateB();
        // foreach(Creator creator in creators){
        //     Product product =creator.FactoryMethod();
        //     Console.WriteLine("create {0}",product.GetType().Name);
        // }
        // Console.ReadKey();
        //Proxy proxy=new Proxy();
        //proxy.Request();
        //Console.ReadKey();
        //  Thread thread=new Thread(new ThreadStart(ThreadExample.ThreadProc));
        //  thread.Start();
        //  for (int i = 0; i < 4; i++) 
        //  {
        //     Console.WriteLine("Main thread: Do some work.");
        //     Thread.Sleep(0);
        //  }
        //  Console.WriteLine("Main thread: Call Join(),to wait until ThreadProc ends.");
        // //  等待主线程执行完
        //  thread.Join();
        //  Console.WriteLine("Main thread: ThreadProc.Join has returnd. Press Enter to end program");
        //  Console.ReadLine()
        // ThreadPool.QueueUserWorkItem(ThreadPoolExample.ThreadProc);
        //  Console.WriteLine("Main thread does some work, then sleeps.");
        // Thread.Sleep(1000);
        // Console.WriteLine("Main thread exits.");
    }
}